//package xyz.erupt.flow.process.listener.impl.MonitorsImpl;
//
//import lombok.extern.slf4j.Slf4j;
//import lombok.var;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.context.ApplicationContext;
//import org.springframework.stereotype.Component;
//import xyz.erupt.flow.bean.entity.OaProcessInstance;
//import xyz.erupt.flow.bean.entity.OaTask;
//import xyz.erupt.flow.process.listener.ExecutableNodeListener;
//import xyz.erupt.upms.service.EruptContextService;
//import xyz.erupt.upms.service.EruptUserService;
//
///**
// * @author PP
// * @version 1.0
// * @project Erupt
// * @description 审批被拒绝后监听
// * @date 2024/8/30 15:25:04
// */
//@Slf4j
//@Component
//public class RejectMonitor implements ExecutableNodeListener<OaTask> {
//
//    //javaspringEl调用bean的上下文
//    @Autowired
//    ApplicationContext applicationContext;
//    @Autowired
//    EruptUserService eruptUserService;
//    @Autowired
//    EruptContextService eruptContextService;
//    @Autowired
//    ProcessNodeEngine processNodeEngine;
//    @Autowired
//    ProcessInstanceService processInstanceService;
//    @Autowired
//    ProcessInstanceHistoryService processInstanceHistoryService;
//    @Autowired
//    ProcessDefinitionService processDefinitionService;
//    @Override
//    public void execute(OaTask executableNode) {
//        log.info(executableNode.getTaskName()+":驳回审批");
//        //当任务被驳回时，分两种情况，一种直接结束，另一种驳回指定节点,当流程直接结束时候无法获取该运行实例，可从历史中获取
//        var oaProcessInstance =  processInstanceService.getById(executableNode.getProcessInstId());//查询流程实例数据
//        if (oaProcessInstance == null){//无法获取运行实例时从历史中获取
//             var data = processInstanceHistoryService.getById(executableNode.getProcessInstId());
//             oaProcessInstance = new OaProcessInstance();
//             oaProcessInstance.setId(data.getId());
//             oaProcessInstance.setFormId(data.getFormId());
//             oaProcessInstance.setBusinessKey(data.getBusinessKey());
//             oaProcessInstance.setBusinessTitle(data.getBusinessTitle());
//             oaProcessInstance.setFormName(data.getFormName());
//             oaProcessInstance.setFormItems(data.getFormItems());
//             oaProcessInstance.setProcessDefId(data.getProcessDefId());
//             oaProcessInstance.setProcess(processDefinitionService.getById(data.getProcessDefId()).getProcess());
//        }
//        var rejects = oaProcessInstance.getProcessNode().getMonitors().getRejectMonitors();
//        for (var reject:rejects) {
//            Utils.DoMonitor(reject,oaProcessInstance,applicationContext,eruptContextService);//执行流程监听代码
//        }
//    }
//}
